#!/usr/bin/perl
# reverses both words on a line and letters in a word
use strict;

binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

while (<>) {
  chomp;
  my @outwords = ();
  my @words = reverse(split / /, $_);
  foreach my $word (@words) {
    my @letters = reverse(split //, $word);
    push @outwords, join("", @letters);
  }
  print join(" ", @outwords)."\n";
}
